var common = function() {
	var e = function(e) {
			var t, n = new RegExp("(^| )" + e + "=([^;]*)(;|$)");
			return (t = document.cookie.match(n)) ? decodeURIComponent(t[2]) : null
		},
		t = function(e) {
			var t;
			for (t in e) return !1;
			return !0
		},
		n = function(e) {
			return !(!e || "object" != typeof e || Array != e.constructor)
		},
		r = function(e) {
			var t = new RegExp("(^|&)" + e + "=([^&]*)(&|$)"),
				n = window.location.search.substr(1).match(t);
			return null != n ? n[2] : null
		},
		o = function(e) {
			var t = "",
				r = new Array;
			for (var o in e) r.push(o);
			r = r.sort();
			for (var i in r) {
				var a = e[r[i]];
				if (n(a)) {
					var c = "";
					for (var s in a) {
						var u = a[s];
						if (n(u))
							for (var d in u) c += u[d];
						else c += u
					}
					a = c
				}
				t += r[i] + "=" + a + "&"
			}
			return t += "key=" + common.secret, console.log(t), md5(t)
		},
		i = function(e, t, n, r, o) {
			function i(e, t, n) {
				if (0 == a.code) {
					var r = a.data.jsApiParameters;
					r = JSON.parse(r), WeixinJSBridge.invoke("getBrandWCPayRequest", r, function(r) {
						c = !1, "get_brand_wcpay_request:ok" == r.err_msg ? (e(), console.log("充值成功!", 1)) :
							"get_brand_wcpay_request:cancel" == r.err_msg ? (t(), console.log("取消充值!")) : (n(), console.log("充值失败!"))
					}), setTimeout(function() {
						c && o()
					}, 1e4)
				}
			}
			var a = e,
				c = !0;
			"undefined" == typeof WeixinJSBridge ? document.addEventListener ? document.addEventListener("WeixinJSBridgeReady",
				i, !1) : document.attachEvent && (document.attachEvent("WeixinJSBridgeReady", i), document.attachEvent(
				"onWeixinJSBridgeReady", i)) : i(t, n, r)
		},
		a = function(e) {
			switch (e.code) {
				case 1:
					return "请求异常";
				case 2:
					return "openid为空或无效";
				case 3:
					return "参数错误";
				case 4:
					return "无效token";
				case 5:
					return "token校验失败";
				case 6:
					return "设置redis错误";
				case 7:
					return "更新数据库信息错误";
				case 30:
					return "错误的参数，缺少receipt参数或receipt参数错误";
				case 31:
					return "苹果支付验证失败";
				case 32:
					return "生成订单失败";
				case 33:
					return "生成订单成功，但更新账号截止时间失败";
				case 34:
					return "调用微信支付失败"
			}
		},
		c = function(e, t) {
			var n = t || (new Date).getTime();
			if (n < e) return new Date(e).Format("yyyy-MM-dd");
			var r = n - e,
				o = r / 864e5,
				i = r / 36e5,
				a = r / 6e4;
			return o >= 1 ? new Date(e).Format("yyyy/MM/dd hh:ss") : i >= 1 ? parseInt(i) + "个小时前" : a >= 1 ? parseInt(a) +
				"分钟前" : "刚刚"
		};
	Date.prototype.Format = function(e) {
		var t = {
			"M+": this.getMonth() + 1,
			"d+": this.getDate(),
			"h+": this.getHours(),
			"m+": this.getMinutes(),
			"s+": this.getSeconds(),
			"q+": Math.floor((this.getMonth() + 3) / 3),
			S: this.getMilliseconds()
		};
		/(y+)/.test(e) && (e = e.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
		for (var n in t) new RegExp("(" + n + ")").test(e) && (e = e.replace(RegExp.$1, 1 == RegExp.$1.length ? t[n] : (
			"00" + t[n]).substr(("" + t[n]).length)));
		return e
	};
	var s = location.href,
		u = "",
		d = "";
	return -1 != s.indexOf("w2gou.com/h5/") ? (u = "//www.w2gou.com/api", d = "https://www.w2gou.com/h5/img") : (u =
		"//www.w2gou.com/apitest", d = "https://www.w2gou.com/h5test/img"), {
		apihost: u,
		imgapi: d,
		cdnimg: "https://img.w2gou.com",
		version: 201806241742,
		unionid: e("unionid") ? e("unionid") : "",
		openid: e("new_openid") ? e("new_openid") : "",
		uid: e("uid") ? e("uid") : "",
		nickName: e("nickname") ? e("nickname") : "",
		isApp: e("isApp") ? e("isApp") : 0,
		secret: "01cf48f730a63792460225ed3f48a319",
		customerSrv: "https://www.w2gou.com/api/NewWeChat/customerSrv",
		isEmptyObject: t,
		isArray: n,
		getUrlParam: r,
		encrypt: o,
		failPrompt: a,
		wxPay: i,
		dateDiff: c
	}
}();